package com.yft.data.controller;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.yft.data.Teacher;
import com.yft.data.service.PersonService;

@Controller
@RequestMapping("teacher")
public class TeacherController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(TeacherController.class);
	@Autowired
	private PersonService personService;
	
	@RequestMapping(value = "teacherlist/{pageno}/{pagesize}", method = RequestMethod.GET)
	public @ResponseBody List<Teacher> getTeacherList(@PathVariable("pageno")int pageno, @PathVariable("pagesize")int pagesize){
		logger.info("url == teacherlist/list");
//		ModelAndView ma = new ModelAndView();
		List<Teacher> maplist = personService.getTeacherList(pageno, pagesize);
		// 返回的view名称
//		ma.addObject("maplist", maplist);
//		ma.addObject("pageno", pageno);
//		ma.addObject("pagesize", pagesize);
//		ma.setViewName("food/getlist");
		return maplist;
	}
	//根据ID查询老师
	@RequestMapping(value = "getbyid/{id}", method = RequestMethod.GET)
	public @ResponseBody Teacher getTeacherByID(@PathVariable("id")int id){
		logger.info("url == teacherlist/getbyid");
//		ModelAndView ma = new ModelAndView();
		Teacher teacher = personService.getTeacherByID(id);
//		List<Map<String,Object>> experience = personService.getExperienceByTid(teacher.getT_id());
//		teacher.setExperience(experience);
		// 返回的view名称
//		ma.addObject("maplist", maplist);
//		ma.addObject("pageno", pageno);
//		ma.addObject("pagesize", pagesize);
//		ma.setViewName("food/getlist");
		return teacher;
	}
}
